﻿namespace SAD.ClientLogic
{
    using System;
    using SAD.Common.Contracts.ShowNode;

    public class InfoReceiverService : IInfoReceiver
    {
        #region IInfoReceiver 成员

        public void AddInfo(SAD.Common.Models.Info_Data info)
        {
            InfoReceiver.Instance.AddInfo(info);
        }

        public void RemoveInfo(long infoID, int categoryID)
        {
            InfoReceiver.Instance.RemoveInfo(infoID, categoryID);
        }

        #endregion
    }

    public class InfoReceiver
    {
        public delegate void AddInfoHandler(SAD.Common.Models.Info_Data info);
        public event AddInfoHandler AddInfoEvent;

        public delegate void RemoveInfoHandler(long infoID, int categoryID);
        public event RemoveInfoHandler RemoveInfoEvent;

        #region Instance
        /// <summary>
        /// 类型单例
        /// </summary>
        public static InfoReceiver Instance
        {
            get
            {
                return m_Instance;
            }
        }
        private static InfoReceiver m_Instance = new InfoReceiver();
        #endregion

        private InfoReceiver()
        {
        }

        public void AddInfo(SAD.Common.Models.Info_Data info)
        {
            if (AddInfoEvent != null)
            {
                AddInfoEvent(info);
            }
        }

        public void RemoveInfo(long infoID, int categoryID)
        {
            if (RemoveInfoEvent != null)
            {
                RemoveInfoEvent(infoID, categoryID);
            }
        }
    }
}